<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Rotation;
use Illuminate\Http\Request;

class ClientHomeController extends Controller
{
    /**
     * @param Request $request
     * 首页展示
     */
    public function clientHome(Request $request)
    {
       //轮播图展示
       $rotation=Rotation::rotationList();
       $rotation=self::handleImage($rotation,'image');
       $data['imageList']=$rotation;
       return response()->json($data);
    }

    /**
     * 处理图片拼接域名
     */
    public static function handleImage($data,$field)
    {
        $imageList=[];
      foreach ($data as $key=>$value){
          $imageList[$key]='http://house.hhnwxs.cn/'.$value[$field];
      }
      return $imageList;
    }
}
